package main

// main
//
//	@Description: 03-抽象工厂：每个工厂类可以创建一组相关产品（抽象工厂生产一组抽象产品）
func main() {
	xiaoMiFactory := XiaoMiFactory{}
	xiaoPhone := xiaoMiFactory.makePhone()
	xiaoPhone.call()

	xiaoPc := xiaoMiFactory.makePc()
	xiaoPc.doWork()

	huaWeiFactory := HuaWeiFactory{}
	huaWeiPhone := huaWeiFactory.makePhone()
	huaWeiPhone.call()

	huaWeiPc := huaWeiFactory.makePc()
	huaWeiPc.doWork()
}

// AbstractFactory
// @Description: 抽象工厂
type AbstractFactory interface {
	//制造抽象产品1
	makePhone() Phone
	//制造抽象产品2
	makePC() PC
}

type XiaoMiFactory struct {
}

func (XiaoMiFactory) makePhone() Phone {
	return XiaoMiPhone{}
}

func (XiaoMiFactory) makePc() PC {
	return XiaoMiPc{}
}

type HuaWeiFactory struct {
}

func (HuaWeiFactory) makePhone() Phone {
	return HuaWeiPhone{}
}
func (HuaWeiFactory) makePc() PC {
	return HuaWeiPC{}
}

type Phone interface {
	call()
}
type PC interface {
	doWork()
}

type XiaoMiPhone struct {
}

type HuaWeiPhone struct {
}

func (HuaWeiPhone) call() {
	println("华为手机打电话")
}

func (XiaoMiPhone) call() {
	println("小米手机打电话")
}

type XiaoMiPc struct {
}

type HuaWeiPC struct {
}

func (HuaWeiPC) doWork() {
	println("华为PC---")
}

func (XiaoMiPc) doWork() {
	println("小米PC---")
}
